<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        {{ myname.substring(0,1).toUpperCase() + myname.substring(1) }}

        <p>普通方法:{{ getMyNameMethod() }}</p>

        <p>计算属性:{{ getMyName }}</p>
    </div>

    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                myname: 'xiaoming'
            },
            methods: {
                getMyNameMethod(){
                    console.log(this)
                    return this.myname.substring(0,1).toUpperCase() + this.myname.substring(1)
                }  
            },
            computed: {
                getMyName(){
                    //1.  依赖的状态改变了 ，计算属性 会重新计算一遍 
                    //2.  计算属性会缓存
                    return this.myname.substring(0,1).toUpperCase() + this.myname.substring(1)
                }
            }
        })
    </script>
</body>
</html>